package com.zhanglijie.base.sync.mardwordDetail;

import org.openjdk.jol.info.ClassLayout;
import org.openjdk.jol.vm.VM;

/**
 * @author zhanglijie
 * @version 1.0
 * @since 1.1.0 2022/6/18 0018 14:32
 *  System.out.println(VM.current().details());
 * 无锁验证
 */
public class NoLockTest {
    static MyObject myObject = null;

    public static void main(String[] args) {

        myObject = new MyObject();
        /**
         * 无锁状态
         * 计算 hash了才会将hash信息放到markword的bit位中
         */
        System.out.println("hash之前");
        System.out.println(ClassLayout.parseInstance(myObject)
            .toPrintable());
        System.out.println("计算hashCode----- 0x" + Integer.toHexString(myObject.hashCode()));
        System.out.println("hash之后");
        System.out.println(ClassLayout.parseInstance(myObject)
            .toPrintable());

    }
}
